home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / JSplitPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  7.8 KB  |  352 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Graphics;
  6. import java.awt.LayoutManager;
  7. import java.io.IOException;
  8. import java.io.ObjectOutputStream;
  9. import javax.accessibility.Accessible;
  10. import javax.accessibility.AccessibleContext;
  11. import javax.swing.plaf.SplitPaneUI;
  12.  
  13. public class JSplitPane extends JComponent implements Accessible {
  14.    private static final String uiClassID = "SplitPaneUI";
  15.    public static final int VERTICAL_SPLIT = 0;
  16.    public static final int HORIZONTAL_SPLIT = 1;
  17.    public static final String LEFT = "left";
  18.    public static final String RIGHT = "right";
  19.    public static final String TOP = "top";
  20.    public static final String BOTTOM = "bottom";
  21.    public static final String DIVIDER = "divider";
  22.    public static final String ORIENTATION_PROPERTY = "orientation";
  23.    public static final String CONTINUOUS_LAYOUT_PROPERTY = "continuousLayout";
  24.    public static final String DIVIDER_SIZE_PROPERTY = "dividerSize";
  25.    public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = "oneTouchExpandable";
  26.    public static final String LAST_DIVIDER_LOCATION_PROPERTY = "lastDividerLocation";
  27.    protected int orientation;
  28.    protected boolean continuousLayout;
  29.    protected Component leftComponent;
  30.    protected Component rightComponent;
  31.    protected int dividerSize;
  32.    protected boolean oneTouchExpandable;
  33.    protected int lastDividerLocation;
  34.  
  35.    public JSplitPane() {
  36.       this(1, false, new JButton("left button"), new JButton("right button"));
  37.    }
  38.  
  39.    public JSplitPane(int var1) {
  40.       this(var1, false);
  41.    }
  42.  
  43.    public JSplitPane(int var1, Component var2, Component var3) {
  44.       this(var1, false, var2, var3);
  45.    }
  46.  
  47.    public JSplitPane(int var1, boolean var2) {
  48.       this(var1, var2, (Component)null, (Component)null);
  49.    }
  50.  
  51.    public JSplitPane(int var1, boolean var2, Component var3, Component var4) {
  52.       ((Container)this).setLayout((LayoutManager)null);
  53.       ((JComponent)this).setOpaque(true);
  54.       this.orientation = var1;
  55.       if (this.orientation != 1 && this.orientation != 0) {
  56.          throw new IllegalArgumentException("cannot create JSplitPane, orientation must be one of JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT");
  57.       } else {
  58.          this.continuousLayout = var2;
  59.          if (var3 != null) {
  60.             this.setLeftComponent(var3);
  61.          }
  62.  
  63.          if (var4 != null) {
  64.             this.setRightComponent(var4);
  65.          }
  66.  
  67.          this.updateUI();
  68.       }
  69.    }
  70.  
  71.    protected void addImpl(Component var1, Object var2, int var3) {
  72.       if (var2 != null && !(var2 instanceof String)) {
  73.          throw new IllegalArgumentException("cannot add to layout: constraint must be a string (or null)");
  74.       } else {
  75.          if (var2 == null) {
  76.             if (this.getLeftComponent() == null) {
  77.                var2 = "left";
  78.             } else if (this.getRightComponent() == null) {
  79.                var2 = "right";
  80.             }
  81.          }
  82.  
  83.          if (var2 == null || !var2.equals("left") && !var2.equals("top")) {
  84.             if (var2 != null && (var2.equals("right") || var2.equals("bottom"))) {
  85.                Component var5 = this.getRightComponent();
  86.                if (var5 != null) {
  87.                   this.remove(var5);
  88.                }
  89.  
  90.                this.rightComponent = var1;
  91.                var3 = -1;
  92.             } else if (var2 != null && var2.equals("divider")) {
  93.                var3 = -1;
  94.             }
  95.          } else {
  96.             Component var4 = this.getLeftComponent();
  97.             if (var4 != null) {
  98.                this.remove(var4);
  99.             }
  100.  
  101.             this.leftComponent = var1;
  102.             var3 = -1;
  103.          }
  104.  
  105.          super.addImpl(var1, var2, var3);
  106.          ((JComponent)this).revalidate();
  107.          ((Component)this).repaint();
  108.       }
  109.    }
  110.  
  111.    public AccessibleContext getAccessibleContext() {
  112.       if (super.accessibleContext == null) {
  113.          super.accessibleContext = new AccessibleJSplitPane(this);
  114.       }
  115.  
  116.       return super.accessibleContext;
  117.    }
  118.  
  119.    public Component getBottomComponent() {
  120.       return this.rightComponent;
  121.    }
  122.  
  123.    public int getDividerLocation() {
  124.       SplitPaneUI var1 = this.getUI();
  125.       return var1 != null ? var1.getDividerLocation(this) : -1;
  126.    }
  127.  
  128.    public int getDividerSize() {
  129.       return this.dividerSize;
  130.    }
  131.  
  132.    public int getLastDividerLocation() {
  133.       return this.lastDividerLocation;
  134.    }
  135.  
  136.    public Component getLeftComponent() {
  137.       return this.leftComponent;
  138.    }
  139.  
  140.    public int getMaximumDividerLocation() {
  141.       SplitPaneUI var1 = this.getUI();
  142.       return var1 != null ? var1.getMaximumDividerLocation(this) : -1;
  143.    }
  144.  
  145.    public int getMinimumDividerLocation() {
  146.       SplitPaneUI var1 = this.getUI();
  147.       return var1 != null ? var1.getMinimumDividerLocation(this) : -1;
  148.    }
  149.  
  150.    public int getOrientation() {
  151.       return this.orientation;
  152.    }
  153.  
  154.    public Component getRightComponent() {
  155.       return this.rightComponent;
  156.    }
  157.  
  158.    public Component getTopComponent() {
  159.       return this.leftComponent;
  160.    }
  161.  
  162.    public SplitPaneUI getUI() {
  163.       return (SplitPaneUI)super.ui;
  164.    }
  165.  
  166.    public String getUIClassID() {
  167.       return "SplitPaneUI";
  168.    }
  169.  
  170.    public boolean isContinuousLayout() {
  171.       return this.continuousLayout;
  172.    }
  173.  
  174.    public boolean isOneTouchExpandable() {
  175.       return this.oneTouchExpandable;
  176.    }
  177.  
  178.    public boolean isValidateRoot() {
  179.       return true;
  180.    }
  181.  
  182.    protected void paintChildren(Graphics var1) {
  183.       super.paintChildren(var1);
  184.       SplitPaneUI var2 = this.getUI();
  185.       if (var2 != null) {
  186.          Graphics var3 = SwingGraphics.createSwingGraphics(var1);
  187.          var2.finishedPaintingChildren(this, var3);
  188.          var3.dispose();
  189.       }
  190.  
  191.    }
  192.  
  193.    protected String paramString() {
  194.       String var1 = this.orientation == 1 ? "HORIZONTAL_SPLIT" : "VERTICAL_SPLIT";
  195.       String var2 = this.continuousLayout ? "true" : "false";
  196.       String var3 = this.oneTouchExpandable ? "true" : "false";
  197.       return super.paramString() + ",continuousLayout=" + var2 + ",dividerSize=" + this.dividerSize + ",lastDividerLocation=" + this.lastDividerLocation + ",oneTouchExpandable=" + var3 + ",orientation=" + var1;
  198.    }
  199.  
  200.    public void remove(int var1) {
  201.       Component var2 = ((Container)this).getComponent(var1);
  202.       if (var2 == this.leftComponent) {
  203.          this.leftComponent = null;
  204.       } else if (var2 == this.rightComponent) {
  205.          this.rightComponent = null;
  206.       }
  207.  
  208.       super.remove(var1);
  209.       ((JComponent)this).revalidate();
  210.       ((Component)this).repaint();
  211.    }
  212.  
  213.    public void remove(Component var1) {
  214.       if (var1 == this.leftComponent) {
  215.          this.leftComponent = null;
  216.       } else if (var1 == this.rightComponent) {
  217.          this.rightComponent = null;
  218.       }
  219.  
  220.       super.remove(var1);
  221.       ((JComponent)this).revalidate();
  222.       ((Component)this).repaint();
  223.    }
  224.  
  225.    public void removeAll() {
  226.       this.leftComponent = this.rightComponent = null;
  227.       super.removeAll();
  228.       ((JComponent)this).revalidate();
  229.       ((Component)this).repaint();
  230.    }
  231.  
  232.    public void resetToPreferredSizes() {
  233.       SplitPaneUI var1 = this.getUI();
  234.       if (var1 != null) {
  235.          var1.resetToPreferredSizes(this);
  236.       }
  237.  
  238.    }
  239.  
  240.    public void setBottomComponent(Component var1) {
  241.       this.setRightComponent(var1);
  242.    }
  243.  
  244.    public void setContinuousLayout(boolean var1) {
  245.       boolean var2 = this.continuousLayout;
  246.       this.continuousLayout = var1;
  247.       ((JComponent)this).firePropertyChange("continuousLayout", var2, var1);
  248.    }
  249.  
  250.    public void setDividerLocation(double var1) {
  251.       if (!(var1 < (double)0.0F) && !(var1 > (double)1.0F)) {
  252.          if (this.getOrientation() == 0) {
  253.             this.setDividerLocation((int)((double)(((JComponent)this).getHeight() - this.getDividerSize()) * var1));
  254.          } else {
  255.             this.setDividerLocation((int)((double)(((JComponent)this).getWidth() - this.getDividerSize()) * var1));
  256.          }
  257.  
  258.       } else {
  259.          throw new IllegalArgumentException("proportional location must be between 0.0 and 1.0.");
  260.       }
  261.    }
  262.  
  263.    public void setDividerLocation(int var1) {
  264.       SplitPaneUI var2 = this.getUI();
  265.       if (var2 != null) {
  266.          var2.setDividerLocation(this, var1);
  267.       }
  268.  
  269.    }
  270.  
  271.    public void setDividerSize(int var1) {
  272.       int var2 = this.dividerSize;
  273.       if (var2 != var1) {
  274.          this.dividerSize = var1;
  275.          ((JComponent)this).firePropertyChange("dividerSize", var2, var1);
  276.       }
  277.  
  278.    }
  279.  
  280.    public void setLastDividerLocation(int var1) {
  281.       int var2 = this.lastDividerLocation;
  282.       this.lastDividerLocation = var1;
  283.       ((JComponent)this).firePropertyChange("lastDividerLocation", var2, var1);
  284.    }
  285.  
  286.    public void setLeftComponent(Component var1) {
  287.       if (var1 == null) {
  288.          if (this.leftComponent != null) {
  289.             this.remove(this.leftComponent);
  290.             this.leftComponent = null;
  291.          }
  292.       } else {
  293.          ((Container)this).add(var1, "left");
  294.       }
  295.  
  296.    }
  297.  
  298.    public void setOneTouchExpandable(boolean var1) {
  299.       boolean var2 = this.oneTouchExpandable;
  300.       this.oneTouchExpandable = var1;
  301.       ((JComponent)this).firePropertyChange("oneTouchExpandable", var2, var1);
  302.       ((Component)this).repaint();
  303.    }
  304.  
  305.    public void setOrientation(int var1) {
  306.       if (var1 != 0 && var1 != 1) {
  307.          throw new IllegalArgumentException("JSplitPane: orientation must be one of JSplitPane.VERTICAL_SPLIT or JSplitPane.HORIZONTAL_SPLIT");
  308.       } else {
  309.          int var2 = this.orientation;
  310.          this.orientation = var1;
  311.          ((JComponent)this).firePropertyChange("orientation", var2, var1);
  312.       }
  313.    }
  314.  
  315.    public void setRightComponent(Component var1) {
  316.       if (var1 == null) {
  317.          if (this.rightComponent != null) {
  318.             this.remove(this.rightComponent);
  319.             this.rightComponent = null;
  320.          }
  321.       } else {
  322.          ((Container)this).add(var1, "right");
  323.       }
  324.  
  325.    }
  326.  
  327.    public void setTopComponent(Component var1) {
  328.       this.setLeftComponent(var1);
  329.    }
  330.  
  331.    public void setUI(SplitPaneUI var1) {
  332.       if ((SplitPaneUI)super.ui != var1) {
  333.          super.setUI(var1);
  334.          ((JComponent)this).revalidate();
  335.       }
  336.  
  337.    }
  338.  
  339.    public void updateUI() {
  340.       this.setUI((SplitPaneUI)UIManager.getUI(this));
  341.       ((JComponent)this).revalidate();
  342.    }
  343.  
  344.    private void writeObject(ObjectOutputStream var1) throws IOException {
  345.       var1.defaultWriteObject();
  346.       if (super.ui != null && this.getUIClassID().equals("SplitPaneUI")) {
  347.          super.ui.installUI(this);
  348.       }
  349.  
  350.    }
  351. }
  352.